# OpenHarmony Knowledge Service Dockerfile
FROM openjdk:17-jdk-slim

# 设置工作目录
WORKDIR /app

# 安装必要的工具
RUN apt-get update && \
    apt-get install -y curl && \
    rm -rf /var/lib/apt/lists/*

# 复制Maven构建产物
COPY target/openharmony-knowledge-service-1.0.0.jar app.jar

# 创建数据目录
RUN mkdir -p /app/data/index /app/logs

# 暴露端口
EXPOSE 8087

# 设置环境变量
ENV JAVA_OPTS="-Xms512m -Xmx2048m -XX:+UseG1GC"
ENV OH_CODE_PATH="/ohcode"
ENV GLM_API_KEY=""

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:8087/actuator/health || exit 1

# 启动应用
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

